<html>
<head>
 <!--
    CPAINT (Cross-Platform Asynchronous INterface Toolkit) - Version 2

    http://sf.net/projects/cpaint
    
    released under the terms of the GPL
    see http://www.fsf.org/licensing/licenses/gpl.txt for details

    authors:  Paul Sullivan <wiley14@gmail.com>, Dominique Stender <dstender@st-webdevelopment.de>
    Copyright (c) 2005-2006 Paul Sullivan, Dominique Stender - http://sf.net/projects/cpaint
  //-->
  <title>cpaint2 encoding test</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  <script type="text/javascript" src="../../cpaint2.inc.compressed.js"></script>
  <script type="text/javascript">
  <!--
      var cp = new cpaint();
      cp.set_debug(0);
    
        function test_ascii() {
          cp.call('encoding.php', 'encode', response, 'ascii');
        }

        function test_nonprintable() {
          cp.call('encoding.php', 'encode', response, 'nonprintable');
        }

        function test_problematic() {
          cp.call('encoding.php', 'encode', response, 'problematic');
        }

        function test_german() {
          cp.call('encoding.php', 'encode', response, 'german');
        }

        function test_swedish() {
          cp.call('encoding.php', 'encode', response, 'swedish');
        }

        function test_arabic() {
          cp.call('encoding.php', 'encode', response, 'arabic');
        }

        function test_russian() {
          cp.call('encoding.php', 'encode', response, 'russian');
        }

        function test_greek() {
          cp.call('encoding.php', 'encode', response, 'greek');
        }

        function test_hebrew() {
          cp.call('encoding.php', 'encode', response, 'hebrew');
        }

        function test_japanese() {
          cp.call('encoding.php', 'encode', response, 'japanese');
        }

        function test_chinese() {
          cp.call('encoding.php', 'encode', response, 'chinese');
        }

        function response(result) {
          var res = document.getElementById('response');

          if (res
            && typeof result == 'object') {
            // top level node has been named 'encoding' by the backend, its not 'ajaxResponse'!
            if (result.encoding[0]
              && result.encoding[0].charset) {
          
              res.innerHTML = '';
          
              for (var i = 0; i <result.encoding[0].charset.length; i++) {
                res.innerHTML += '<strong>' + result.encoding[0].charset[i].get_attribute('id') + ': </strong><br />'
                              + result.encoding[0].charset[i].data + '<br /><br />';
              }
            }
      
          } else if (res
            && typeof result == 'string') {
        
            res.innerHTML = result;
          }
        }
  //-->
  </script>
</head>
<body>
  Verifying the ability of CPAINT to handle arbitrary charsets. The data being put in the backend is
  converted to UTF-8, where non-printable characters are additionally converted to the sequence \u00xy
  which is the standard JavaScript representation.<br />
  <br />
  <strong>NOTE:</strong> The conversion to UTF-8 is performed only if the iconv extension of PHP is available
  or if the input characterset is ISO-8859-1, which can be converted by other means. If both is not the 
  case the characters are cleaned up to form valid XML and are sent as-is. This should still work.
  <br />
  Without this extra conversion most browsers' XML parsers will crash.<br />
  <br />
  CPAINT frontend decodes the character stream before handing it to the callback function.<br />
  <br />
  
  <strong>single-byte charactersets:</strong><br />
  <a href="#" onClick="javascript:test_ascii()">standard 7bit ASCII</a><br />
  <a href="#" onClick="javascript:test_nonprintable()">non printable characters</a><br />
  <a href="#" onClick="javascript:test_problematic()">common but problematic characters</a><br />
  <a href="#" onClick="javascript:test_german()">german</a><br />
  <a href="#" onClick="javascript:test_swedish()">swedish</a><br />
  <a href="#" onClick="javascript:test_arabic()">arabic</a><br />
  <a href="#" onClick="javascript:test_russian()">russian</a><br />
  <a href="#" onClick="javascript:test_greek()">greek</a><br />
  <a href="#" onClick="javascript:test_hebrew()">hebrew</a><br />
  <br />
  <strong>multi-byte charactersets:</strong><br />
  <a href="#" onClick="javascript:test_japanese()">japanese (EUC-JP)</a><br />
  <a href="#" onClick="javascript:test_chinese()">chinese (Big5)</a><br />
  <br />
  <div id="response"></div>
</body>
</html>
